<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: wsh
 * @Date: 2024-01-31 14:59:38
 * @LastEditors: wsh
 * @LastEditTime: 2024-02-01 14:26:13
-->
<!-- 指静脉采集审核 -->
<template>
  <BaseContainer>
    <aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig">
      <template v-slot:menuColumn="{ row }">
        <span v-if="row.approveStatus == 0">
          <el-button text type="primary" plain @click="handleOperate(row, 'through')">通过</el-button>
          <!-- <el-button text type="primary" plain>撤销</el-button> -->
          <el-button text type="primary" plain @click="handleOperate(row, 'turnDown')">驳回</el-button>
        </span>
      </template>
    </aplid-base-crud>
    <AplidDialog v-model="visible" width="35%" :rowData="rowData">
      <turnDown v-if="visible && operateType == 'turnDown'" :nowRowData="rowData" @refresh="handleRefresh"></turnDown>
    </AplidDialog>
  </BaseContainer>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod/index'
import { ref, nextTick } from 'vue'
import AplidDialog from '@/views/instOperate/components/AplidDialog/index.vue'
import turnDown from './turnDown/index.vue'
import { baseConfig } from './config'
const crud = ref()
const rowData = ref({})
const visible = ref(false)
const operateType = ref('')

const handleRefresh = (query) => {
  visible.value = false
  nextTick(() => {
    crud.value.refreshChange(query)
  })
}

const handleOperate = (row, type) => {
  visible.value = false
  if (type == 'turnDown') {
    visible.value = true
    rowData.value = row || {}
    operateType.value = type
  } else if (type == 'through') {
    let params = {
      ...row, approveResult: 1, approveStatus: 1
    }
    apiMod.view_iccVeinApprove_edit(params).then(res => {
      handleRefresh({})
      ElMessage({
        message: '审批成功',
        type: 'success',
      })
    }).catch(err => {
      handleRefresh({})
      ElMessage({
        message: '审批异常',
        type: 'warning',
      })
    });
  }
}
</script>

<style scoped lang="scss"></style>
